package 编程能力入门1;

import java.util.Arrays;

public class _02去掉最低工资和最高工资后的工资平均值 {
    public double average(int[] salary) {
        if(salary == null) return 0;
        double min = Integer.MAX_VALUE;
        double max = Integer.MIN_VALUE;
        double sum = 0;
        for (int num : salary) {
            sum += num;
            max = Math.max(max,num);
            min = Math.min(min,num);
        }
        return (sum - min - max) /(salary.length-2);
    }
}
